﻿@using EasyCourse.Model;
@{
    Layout = null;
    ViewData["MenuIndex"] = 11;
    CommonPageInfo pageInfo = ViewData[CommonViewDataKey.CommonPageInfo] as CommonPageInfo;
    ViewData["CourseId"] = pageInfo.CourseId;
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>讨论区</title>
    @Html.Partial("~/Views/Share/PublicHeader.cshtml")
    <link rel="stylesheet" href="../Content/kindeditor/themes/default/default.css" />
    <script charset="utf-8" src="../Content/kindeditor/kindeditor-min.js"></script>
    <script charset="utf-8" src="../Content/kindeditor/lang/zh_CN.js"></script>
    <script>
        var editor;
        KindEditor.ready(function (K) {
            editor = K.create('textarea[name="content"]', {
                resizeType: 1,
                allowPreviewEmoticons: false,
                allowImageUpload: false,
                items: [
                    'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                    'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                    'insertunorderedlist', '|', 'emoticons', 'image', 'link']
            });
        });
    </script>

</head>
<body>
    @Html.Partial("~/Views/Share/PublicTopNav.cshtml")
    <div class="container">
        <div class="row">
            <h1 class="topTitle-h1">
                @pageInfo.CourseName
                <br>
                <small>广州中医药大学康复治疗微课程网络学习平台</small>
            </h1>
        </div>
    </div>
    @Html.Partial("~/Views/Share/PublicNav.cshtml", this.ViewData)
    <div class="container wrap mb10 mainwrap">
        <div class="row">
            <div class="col-xs-9">
                <div class="lBox part mainwrap-part">
                    <div class="lBox-th">
                        <h3>发帖</h3>
                    </div>
                    <div class="lBox-tb">
                        <form class="form-horizontal" role="form">
                            <div class="form-group">
                                <label class="control-label col-xs-1">标题：</label>
                                <div class="col-xs-11">
                                    <input type="text" class="form-control" id="Jtitle" placeholder="请输入标题">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="control-label col-xs-1">内容：</label>
                                <div class="col-xs-11">
                                    <textarea name="content" id="JdiscussionContent" style="width:738px;height:361px;visibility:hidden;"></textarea>
                                </div>
                            </div>
                            <div class="form-group" style="margin-bottom: 9px;">
                                <div class="col-xs-12 text-right">
                                    <button type="button" id="JaddNewPost" class="btn btn-success">发帖</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="col-xs-3">
                @Html.Partial("~/Views/Share/PublicRBox.cshtml", ViewData)
            </div>
        </div>
    </div>
    @Html.Partial("~/Views/Share/PublicFooter.cshtml")
    @Html.Partial("~/Views/Share/PublicCommonJs.cshtml")
    <script>

        var CourseId = $.getUrlParam("CourseId"),
            Title = $("#Jtitle"),
            DiscussionContent = $("#JdiscussionContent"),
            AddNewPost = $("#JaddNewPost");
        AddNewPost.bind("click", function () {
            editor.sync();
            $.easyPost("@Url.Action("DiscussionInfoAdd", "Discussion")", {
                "CourseId": CourseId,
                "Title": Title.val(),
                "DiscussionContent": DiscussionContent.val()
            }, function (data) {
                if (data.result) {
                    showTips.open("发贴成功！");
                    window.location.href = "@Url.Action("Detail", "Discussion")?CourseId=" + CourseId + "&DiscussId=" + data.entity;
                } else {
                    showTips.open(data.message)
                }
            }, "json")
        })
    </script>
</body>
</html>